/***************************************************************
 * Name:      main.cpp
 * Purpose:   command lines
 * Author:    Riku Maikola (riku@maikola.net)
 * Created:   2014-04-01 - 2014-04-21
 * Copyright: Riku Maikola
 * License:
 **************************************************************/

#include <iostream>
#include <fstream>
#include <vector>
#include <stdlib.h>

using namespace std;

int main(int n, char* Args[])
{
    if(n==3)
    {
        vector<string> arg;
        arg.resize(3);
        for(uint a=0;a<3;a++)
        {
            int c =0;
            while(Args[a][c]!=0)
            {
                arg[a] += Args[a][c];
                c++;
            }
        }
        arg[0] = "/opt/MAICAM/conf/simulator.config";

        string line;

        vector<string> rows;
        ifstream codefile(arg[0].c_str());
        if (codefile.is_open())
        {
            for(uint a=0; a<19999; a++)
            {
                if(getline(codefile,line))
                {
                }
                else line="";
                rows.push_back(line);
            }
            codefile.close();
            rows[atoi(arg[1].c_str())] = arg[2];

            ofstream myfile;
            myfile.open(arg[0].c_str());
            if (myfile.is_open())
            {
                for(uint b=0; b<19999; b++)myfile << rows[b] << "\n";
                myfile.close();
            }
        }
    }
    else
    {
        cout << "error\n";
    }
    return 0;
}


